package com.mianyang.zhangsan.controller;


import com.mianyang.zhangsan.common.base.BaseController;
import com.mianyang.zhangsan.common.base.R;
import com.mianyang.zhangsan.model.dto.SecGrant;
import com.mianyang.zhangsan.model.dto.SecGrantAuthDto;
import com.mianyang.zhangsan.service.ISecRoleAuthorityService;
import com.mianyang.zhangsan.service.ISecUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @author jiangjr
 * @since 2022-10-23
 */
@RestController
@RequestMapping("/grant")
public class SecRoleAuthorityController extends BaseController {
    @Autowired
    private ISecRoleAuthorityService roleAuthorityService;
    @Autowired
    private ISecUserRoleService userRoleService;

    /**
     * 为角色授权
     */
    @PostMapping("/role")
    public R grantAuthorities(@RequestBody SecGrant grant) {
        roleAuthorityService.grant(grant);
        return success();
    }

    /**
     * 为用户授予角色
     */
    @PostMapping("/account")
    public R grantRoles(@RequestBody SecGrant grant) {
        userRoleService.grant(grant);
        return success();
    }
}
